Broken Data Wires

While there is no way to improperly order blocks in a program, there are four ways to improperly connect them using data wires. Such connection errors create "broken" data wires that are colored gray. Programs containing broken data wires cannot be downloaded to the NXT.

The four possible data wire errors are:

Type mismatch

Each data wire carries a specific type of data between programming blocks. For example, if a data wire is dragged from a logic output plug on a block’s data hub, it will be carrying logic data. This data wire can only connect to a logic input plug on another block’s data hub.

For the same reason, number output plugs must be connected to number input plugs and text output plugs must be connected to text input plugs.

A type mismatch error occurs if you connect a data wire between plugs that handle different types of data, for example, connecting a logic output plug to a text input plug.

Avoid this error by paying particular attention to the data types of the plugs you are attaching data wires to.

Example:
Suppose you would like to display a number on your NXTs screen.

In the first program shown below, a data wire is attempting to carry number data to a text input port. The data wire is "broken" and colored gray. This program is invalid and cannot be downloaded.

In the corrected program, a Text Format block (found in the Advanced block palette) has been added to first convert the number data to text. Then the text output from the Text Format block is carried to the Display block’s text input plug. This program is valid and can be downloaded.

Cycle

Given any set of blocks and wires, if you are able to follow a wire path that visits the same block twice, you have a cycle. This will cause broken data wires and an invalid program.

The solution is to remove one or more wires from the cycle.

Example:
Suppose you want to create a program that keeps doubling the duration value for a motor by reading the motor’s current duration, multiplying it by two, and then feeding it back to the motor’s input plug.

The program below will not work because the data wires create a cycle. You can see that the wire path visits each of these blocks twice.

The program below solves the problem by using a number variable to send the doubled duration back in the loop.

Missing input

A data wire without a data source cannot function; it has no data to carry and will be marked as broken.

For instance, on a data hub that has both input and output plugs for a certain property, the output plug will only work if another data wire is also connected to the input plug providing the output plug with a data source.

Example:
Suppose you want to pass data through another block’s data hub.

In the program below, the broken data wire (in gray) has no data to carry because nothing is "passed through" from the input plug. This program is invalid and cannot be downloaded.

In the corrected program below, an input data wire has been connected to the input plug. Number data from the Sound Sensor block can now be passed through the Math block to the Text Convert block.

Too many inputs

More than one data wire connected to the same input plug will cause broken data wires and an invalid program.

The solution to this problem is to delete or move broken data wires so that each input plug is connected to only one output plug.

The illustrations below show an invalid program with broken data wires and then a corrected program.

Deleting a data wire

To delete a data wire that stretches from left to right between two data plugs, click on the right plug.